package com.iiiss.template.ssh.impl.services;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.iiiss.template.ssh.core.beans.IExampleEvent;
import com.iiiss.template.ssh.core.daos.IExampleEventDao;
import com.iiiss.template.ssh.core.services.IExampleEventService;

/*
 * TemplateSSH - com.iiiss.template.ssh.impl.services - ExampleEventService.java
 * 
 * Copyright (C) 2011  Mingye Cheng <Cheng, Mingye at GMAIL>
 * 
 * ExampleEventService.java is part of <iiiStudio Template Framework> project.
 * This project is hosted at <http://iiiss-template-ssh.googlecode.com>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Revision history:
 * [2011-5-30] Mingye Cheng - Initial version established.
 */
public class ExampleEventService implements IExampleEventService {
	@Autowired
	private IExampleEventDao eventDao;

	public void setEventDao(IExampleEventDao eventDao) {
		this.eventDao = eventDao;
	}

	public IExampleEvent triggerRandomEvent() {
		String title = String.valueOf(Math.random());
		return eventDao.createEvent(title);
	}

	public IExampleEvent acquireEvent(long id) {
		return eventDao.getEventById(id);
	}

	public IExampleEvent acquireEvent(String title) {
		return eventDao.getEventByTitle(title);
	}

	public List<IExampleEvent> listAllEvents() {
		return eventDao.getAllEvents();
	}
}
